<div class='fui-page fui-page-current'>
    <div class="fui-header">
        <div class="fui-header-left">
            <a class="back" ng-click="goback();"></a>
        </div>
        <div class="title">商品管理</div>
        <div class="fui-header-right">
          
        </div>
    </div>
    <!-- 顶部tab -->
    <div id="tab" class="fui-tab fui-tab-success fixed">
       
    </div>
    <div class='fui-content' style="margin-top:2.5rem">
		<div class="searchbar" style='margin:0.3rem;padding:0'>
                    <div class="search-input">
                        <i id="searchsub" class="icon icon-search" ng-click="tool.get_list('jy_shopwms/manage.goods/getlist/',true);"></i>
                        <input type="search" id='keywords' ng-model="pagedata.params.keyword" placeholder="输入关键字..." style="border: 1px solid #f7f7f7;">
                    </div>
          </div>

        <!-- 商品列表 -->
       <div ng-repeat="item in pagedata.list" class="fui-list-group order-item">
	   <div class="fui-list" style="padding-bottom:0.2rem;">
			 <div class="fui-list-media batch-item">
                <input type="checkbox" class="fui-radio fui-radio-success batch-item-check" ng-checked="pagedata.post.goodsids.indexOf(';'+item.id+';')>=0" ng-click="duoxuans(item.id,pagedata.post,'goodsids')"/>
            </div>
            <div class="fui-list-media round">
                <img ng-src="{{tomedia(item.image) ||'../core/resource/images/nopic.jpg'}}" class="round"  />
            </div>
            <div class="fui-list-inner">
                <div class="title">{{item.title}}</div>
                <div class="subtitle">
                    <span class="price">￥{{item.price}}</span>
                </div>
                <div class="subtitle">
                    <span class="total">本店库存: {{item.total}}</span>
					<span ng-if="pagedata.is_admin==1" class="total">总库存: {{item.alltotal || 0}} </span>
                    <span class="total">销量: {{item.salenum}}</span>
                </div>
            </div>
		</div>
			<div class="row margin0" style="padding:0.5rem;padding-top:0">
				<span class="status noremark" style="float:right;">
					<div class="btn btn-sm btn-warning-o order-delete" href="javascript:;" ng-click="pagedata.setto('out',item);">出库</div>
					<div class="btn btn-sm btn-default-o order-delete" href="javascript:;" ng-click="pagedata.setto('in',item);">入库</div>
					<div ng-if="pagedata.is_admin==1" class="btn btn-sm btn-primary-o order-delete" href="javascript:;" ng-click="pagedata.setto('diao',item);">调拨</div>
					<div ng-if="pagedata.is_admin==1" class="btn btn-sm btn-default-o order-delete" href="javascript:;" ng-click="pagedata.setto('inmore',item);">多店入库</div>
				</span>
            </div>
        </div>
		<div class="content-empty" ng-show="(!pagedata.list || pagedata.list.length == 0) && !pagedata.loading">
		  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">暂时没有商品！</p>
		</div>
		 <div ng-show="pagedata.loading" class='infinite-loading'><span class='fui-preloader'></span><span class='text'> 正在加载...</span></div>
		<div ng-if="pagedata.post.goodsids"  class="fui-navbar">
			<a href="javascript:;" ng-click="pagedata.setto('out');" class="nav-item" style="background:#ff9326;color:#fff">批量出库</a>
			<a href="javascript:;" ng-click="pagedata.setto('in');" class="nav-item" style="background:#333;color:#fff">批量入库</a>
			<a href="javascript:;" ng-if="pagedata.is_admin==1" ng-click="pagedata.setto('diao');" class="nav-item" style="background:#0290be;color:#fff">调拨出库</a>
		</div>
    </div>
    <div class="head-menu-mask"></div>
</div>
<div ng-if="pagedata.showsettotal" class="popup">
	<div class="popup-body">
		<div class="popup-center" style="border-radius:0.2rem;padding-bottom:3rem;">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showsettotal=false"></i>
			<div ng-if="pagedata.post.ispi!=1" class="fui-cell-title">{{pagedata.g.title}} (<span class="red">库存{{pagedata.g.total}}</span>)</div>
			<div class="fui-cell-group" style="max-height:15rem;overflow-y:scroll;margin-top:0">
				<div ng-if="pagedata.post.type=='out'" class="fui-cell">
					<div class="fui-cell-label">出库数量</div>
					<div class="fui-cell-info"><input type="text" class="fui-input" placeholder="出库数量" ng-model="pagedata.post.num"/></div>
				</div>
				<div ng-if="pagedata.post.type=='in'" class="fui-cell">
					<div class="fui-cell-label">入库数量</div>
					<div class="fui-cell-info"><input type="text" class="fui-input" placeholder="入库数量" ng-model="pagedata.post.num"/></div>
				</div>
				<div ng-if="pagedata.post.type=='diao'" class="fui-cell">
					<div class="fui-cell-label">调拨数量</div>
					<div class="fui-cell-info"><input type="text" class="fui-input" placeholder="调拨数量" ng-model="pagedata.post.num"/></div>
				</div>
				<div ng-if="pagedata.post.type=='diao'" class="fui-cell">
					<div class="fui-cell-label">调入门店</div>
					 <select class="weui_select" name="cateid2" ng-model="pagedata.post.tostoreid">
							<option ng-repeat="q in pagedata.stores" value="{{q.id}}">{{q.title}}</option>
					  </select>
				</div>
				<div ng-if="pagedata.post.type=='inmore'" ng-repeat="q in pagedata.allstores" class="fui-cell">
					<div class="fui-cell-label">{{q.title}}</div>
					<div class="fui-cell-info"><input type="text" class="fui-input" placeholder="入库数量" ng-model="pagedata.post.morenum[q.id]"/></div>
				</div>
				<div class="fui-cell">
					<div class="fui-cell-info c000">
						<textarea rows="5" placeholder="操作备注" ng-model="pagedata.post.remark"></textarea>
					</div>
				</div>
			</div>
			<div class="fui-navbar">
				<a href="javascript:;" ng-click="pagedata.settotal();pagedata.showsettotal=false;" class="nav-item btn btn-danger confirmbtn">确定</a>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
//选择
scope.pagedata.setto=function(type,goods){
	scope.pagedata.showsettotal=true;
	scope.pagedata.post.type=type;
	if(goods){
		scope.pagedata.g=goods;
		scope.pagedata.post.goodsid=goods.id;
	}else{
		scope.pagedata.post.ispi=1;
	}
	scope.$evalAsync();
}
scope.pagedata.settotal=function(){
	scope.post_json('jy_shopwms/manage.goods/settotal/',scope.pagedata.post,function(res){
		scope.message('操作成功！');
	});
}
scope.loading = true;
var page = 1;
var keyword = '';
scope.tool.get_list('jy_shopwms/manage.goods/getlist/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_shopwms/manage.goods/getlist/');
}
   
</script>
